package com.config.ser.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.async.AsyncRequestTimeoutException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@ControllerAdvice

class GlobalControllerExceptionHandler {
    protected static final Logger logger = LoggerFactory.getLogger(GlobalControllerExceptionHandler.class);

    @ResponseStatus(HttpStatus.NOT_MODIFIED)//返回304状态码

    @ResponseBody

    @ExceptionHandler(AsyncRequestTimeoutException.class) //捕获特定异常

    public void handleAsyncRequestTimeoutException(AsyncRequestTimeoutException e, HttpServletRequest request, HttpServletResponse response) {
        response.setStatus(304);
    }

}